package reign.engine.structures;

import java.util.HashMap;
import reign.engine.structures.decks.ResourceDeck;
import reign.engine.structures.decks.SupplyDeck;

public class ResourceSupply {
	private HashMap<String,ResourceDeck> decks;
	private static final int CARD_LIMIT = 10;
	public ResourceSupply()
	{
		decks = new HashMap<String,ResourceDeck>();
	}
	
	public boolean addDeck(String name,ResourceDeck addMe)
	{
		if(decks.size() < CARD_LIMIT)
		{
			decks.put(name, addMe);
		}
		return false;
	}
	
	public ResourceDeck[] addDecks(ResourceDeck [] addme)
	{
		int i = 0;
		for(; i < addme.length;i++)
		{
			if(addDeck(addme[i].getName(),addme[i]) == false)
			{
				break;
			}
		}
		ResourceDeck [] leftOvers = new ResourceDeck[addme.length-i];
		int offset = i;
		for(; i < addme.length;i++)
		{
			leftOvers[i-offset] = addme[i];
		}
		return leftOvers;
	}
	
	public boolean isAdded(String name)
	{
		return (decks.get(name) != null);
	}
	
	public boolean exists(String name, ResourceDeck exists)
	{
		ResourceDeck getIt = decks.get(name);
		return (getIt.equals(exists));
	}
	
	public void remove(String name)
	{
		decks.remove(name);
	}
}
